<?php
namespace app\admin\controller;

use app\common\controller\Base;
use think\facade\View;

class Config extends Base
{
    protected $config=[
        'modelName'=>'config',
    ];
    /**
     * 显示配置页面
     * @return \think\response\View
     */
    public function index()
    {
        if($this->request->isPost()){
            $data=$this->request->param();
        //    数据安全3板斧,1.过滤,验证,字段转换
            $check=$this->validation('\app\admin\validate\Config',$data);
            if($check['status']===0){
                $this->error($check['msg']);
            }
            $jdata['content']=json_encode($data,JSON_UNESCAPED_UNICODE);
            $res=$this->model->save($jdata,['id'=>1]);
            ($res)?$this->success('数据保存成功'):$this->error('数据保存失败');
        }
        return view();
    }
}
